home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9620 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: inforamp.net!ts36-04
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: API's
  5. Date: Sun, 03 Mar 96 05:33:50 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4hbavm$6d8@sam.inforamp.net>
  8. References: <BMagnusson-2802961627410001@204.118.152.122>
  9. NNTP-Posting-Host: ts36-04.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <BMagnusson-2802961627410001@204.118.152.122>,
  13.    BMagnusson@PrecisionImages.com (Baiss E. Magnusson) wrote:
  14. >I have developed API's for our video capture products and I am considering
  15. >changing the design to support functions which may/may not reside in the
  16. >image processor on our PCI video image capture board.
  17. >
  18. >Does anyone know why it is a good/bad idea to use a variable number of
  19. >parameters in C function calls which are part of an API?
  20.  
  21. I'm no video capture guru and I did not consider the first paragraph of your 
  22. posting when I wrote this reply.  Hopefully, my ignorance doesn't matter.  But 
  23. you have several choices.  Your choice will depend on your implementation.  
  24. I'll enumerate some of my thoughts, but you'll have to implement them and 
  25. debug them.
  26.  
  27. 1.  Define some header macros where
  28.     f(x) = f1(x)
  29.     f(x,x1) = f2(x,x1)
  30.     f(x,x1,x2) = f2(x,x1,x2)
  31.     etc.
  32. This will not work where the amount of parameters is unlimited.  Or the types 
  33. of parameters make the macros too cumbersome.
  34.  
  35. 2.  Use C++'s ability to have a function with several sets of parameters.  
  36. You'd have to export a class API in this case.
  37.  
  38. 3.  Use C++'s ability to overload operators.  Instead of using
  39.     f(x,x1,x2,..,xn)
  40. use
  41.     f << x << x1 << x2 << .. << xn
  42. But don't limit yourself to the << operator.  Then following will also work.
  43.     f + x + x1 + x2 + .. + xn
  44. This method is quite hard to visualize and implement.
  45.  
  46. 4.  Use the same calling procedure as the printf commands...
  47.     int printf(const char *format[, argument, ...]);
  48. Obsolete, but easier for conventional C programmers.
  49.  
  50. I hope this helps.
  51.  
  52. Agrivar
  53.